﻿using UnityEngine;

public class SceneObject : Entity, IAwake<string, GameObject, string>, IStart
{
    public string path { get; private set; }
    public Transform transform { get; private set; }
    public string key { get; private set; }

    void IAwake<string, GameObject, string>.Awake(string path, GameObject gameObject, string key)
    {
        this.path = path;
        this.transform = gameObject.transform;
        this.key = key;
    }

    void IStart.Start()
    {
        if (transform != null)
        {
            transform.gameObject.SetActive(true);
        }
    }

    public void SetParent(Transform parent)
    {
        transform.SetParent(parent);
    }

    public void SetPosition(Vector3 position)
    {
        transform.position = position;
    }

    public void SetRotation(Quaternion rotation) 
    {
        transform.rotation = rotation;
    }

    public void SetRotation(Vector3 eulerAngles)
    {
        transform.localEulerAngles = eulerAngles;
    }

    public void SetScale(Vector3 scale)
    {
        transform.localScale = scale;
    }


    public override void Dispose()
    {
        base.Dispose();
        SceneObjectMgr.Instance.RemoveObject(this);
        if(transform != null)
        {
            transform.gameObject.SetActive(false);
        }
    }
}
